﻿
using Maticsoft.DBUtility;
using Maticsoft.Model;

using System;
using System.Data;
using System.Text;
using System.Web.Security;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using Wuqi.Webdiyer;


public partial class WebPage_DiaoCha_Bianji : SystemBBasePage
{
    // Fields

    private Maticsoft.Model.vote_question vq = new Maticsoft.Model.vote_question();
    private Maticsoft.BLL.vote_question vqu = new Maticsoft.BLL.vote_question();

    // Methods
    private void getBianji(int id)
    {
        StringBuilder builder = new StringBuilder();
        StringBuilder builder2 = new StringBuilder();
        StringBuilder builder3 = new StringBuilder();
        StringBuilder builder4 = new StringBuilder();
        StringBuilder builder5 = new StringBuilder();
        foreach (vote_question _question in this.vqu.GetModelList("id=" + id))
        {
            builder.Append("<input type='text' size='30' name='title' class='f-input' value='" + _question.Title + "'/>");
            if (_question.Type == "radio")
            {
                builder2.Append("<input type='radio' name='type' value='radio' checked/>单选");
                builder2.Append("<input type='radio' name='type' value='checkbox' />多选");
            }
            else if (_question.Type == "checkbox")
            {
                builder2.Append("<input type='radio' name='type' value='radio' checked/>单选");
                builder2.Append("<input type='radio' name='type' value='checkbox' checked />多选");
            }
            else
            {
                builder2.Append("<input type='radio' name='type' value='radio' checked/>单选");
                builder2.Append("<input type='radio' name='type' value='checkbox' />多选");
            }
            if (_question.is_show == 1)
            {
                builder3.Append(" <input type='radio' name='is_show' value='1' checked/>显示");
                builder3.Append("<input type='radio' name='is_show' value='0' />隐藏");
            }
            else if (_question.is_show == 0)
            {
                builder3.Append(" <input type='radio' name='is_show' value='1' />显示");
                builder3.Append("<input type='radio' name='is_show' value='0' checked />隐藏");
            }
            else
            {
                builder3.Append(" <input type='radio' name='is_show' value='1' checked/>显示");
                builder3.Append("<input type='radio' name='is_show' value='0' />隐藏");
            }
            builder4.Append("<input type='text' size='30' name='order' class='number' value='" + _question.order + "'/>");
            builder5.Append("<input type='hidden' name='id' value='" + _question.id + "'/>");
        }
        this.Literal1.Text = builder2.ToString();
        this.Literal2.Text = builder3.ToString();
        this.Literal3.Text = builder.ToString();
        this.Literal4.Text = builder4.ToString();
        this.Literal5.Text = builder5.ToString();
    }

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        this.HeaderControl1.Select = "diaocha";
        this.DiaoCha1.Select = "Wenti";
        if (base.Request.QueryString["bianji"] != null)
        {
            this.getBianji(int.Parse(base.Request.QueryString["bianji"].ToString()));
        }
        else if (base.Request.Form["id"] != null)
        {
            this.vq.id = int.Parse(base.Request.Form["id"].ToString());
            this.vq.Title = base.Request.Form["title"].ToString();
            this.vq.Type = base.Request.Form["type"].ToString();
            this.vq.is_show = int.Parse(base.Request.Form["is_show"].ToString());
            this.vq.order = int.Parse(base.Request.Form["order"].ToString());
            this.vqu.Update(this.vq);
            base.SetSuccess("更新成功！");
        }
    }

}